package com.cross.sax;

public class StringReplacer implements Replacer{
	
	private String s1;
	private String s2;
	
	public StringReplacer(String s1, String s2){
		this.s1 = s1;
		this.s2 = s2;
	}
	
	@Override
	public byte[] replace(byte[] buffer, int start, int end) {
		String s = new String(buffer, start, end);
		s = replace(s);
		byte[] temp = s.getBytes();
		return temp;
	}

	@Override
	public String replace(String str) {
		return str.replaceAll(s1, s2);
	}

	@Override
	public char[] replace(char[] buffer, int start, int end) {
		String s = new String(buffer, start, end);
		s = replace(s);
		char[] temp = s.toCharArray();
		return temp;
	}
}
